const express = require('express'); // 框架

const response = require('module/response'); // 响应
const validate = require('module/validate'); // 验证

const emailService = require('service/email-seivice.js');

const router = express.Router(); // 路由

/* 前端调用
methodPost('/email/send', {email: '18011410296@qq.com'}).then(res => {
  if (res.code === 6000) {
    successMsg('发送成功');
  } else {
    errorMsg(res.remark);
  }
}) */
// 发送邮件
router.post("/send", (req, res, next) => {
  let email = req.body.email; // 接受者,可以同时发送多个,以逗号隔开
  let subject = "标题"; // 标题
  let html = "<p>你好</p>";; // html
  emailService.send(email, subject, html, (err) => {
    response(res, null, err);
  })
})

module.exports = router;